package file;

import java.io.*;

public class MakeIndex {
	
	
	/**フォルダ名から適切な条件を判定した上でindex.htmlを作る
	 * 
	 * @param folder	フォルダ名
	 * @throws IOException 
	 */
	public static void checkAndMake(String folder) throws IOException{
		String make = folder.concat("/index.html");
		String[] filenames = FileChanger.fileNames(folder);
		String[] htmlfiles = FileChanger.specificSort(filenames, FileChanger.EXTENTION_HTML);
		File makefile = new File(make);
		if(!makefile.exists()){
			FileChanger.htmlmake(makefile, htmlfiles);
		}else{
			System.out.println("すでにindexが存在します");
		}
	}
	
	public static void main(String args[]) throws IOException{
		System.out.println("探索フォルダ");
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String path = br.readLine();
		checkAndMake(path);
	}

}
